#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include "qtcpsocket.h"
#include "ManageSerialPort.h"
#include "ui_widget.h"
#include "threadsendgps.h"
#include <QDateTime>
#include "clientsocket.h"
#include "threadshell.h"
#include "QRegExp"
namespace Ui {
    class Widget;
}

class Widget : public QWidget , public  Ui::Widget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = 0);
    ~Widget();

private:
    Ui::Widget *ui;
    ManageSerialPort *serialPort;
    QByteArray allDataReceived;
    QByteArray CompleteSts;
    QString uname,upasswd;
    ClientSocket *client;
    QString value1,value2;
private slots:
    void OpenPort(QString devname,int btlv);//打开端口获取gps数据
    void showdata(const QByteArray &);//显示数据
    void stopgps();
    void senddate();//发送数据
    void connectserver();
    void showerror(const QString error);
    void testgps();
    void successTimes();
    void timerUpDate();

 signals:
    void error(const QString error);
    void newDataReceived(const QByteArray &dataReceived);
    void success();//成功信号

public:
    QString address;
    quint16 port;
    int a;
    QString GpsDev; //GPS设备号
    int GpsBotelv;  //GPS波特率
    QString GprsDev;//GPRS设备号
    int GprsBotelv;   //GPRS波特率
    ThreadShell *sh;    //执行连接网络脚本
    ThreadShell *pingsh;//保持网络脚本
    ThreadShell *shnet;
    QTimer *timer ;
public:

    QString gettime();//获取系统时间
    int readfile();//读文件
    int  InitNet();
    int  set_pinlv();//设置频率
    int  writefile(QString text,int pos);
    int initFileInfo();
    void InitAt();
    void TestNet();
    void OpenPPP();
private:
    int frequency;
    int alltimes;
    int phonenumber;

    int serverport; //服务端口
    QString serverip;//Ip地址
    int receive_flag;
    int sendflg;
    int gprsflg;
    int AllSendTimes;
    int SuccessTimes;
    int f_t;


};

#endif // WIDGET_H

